home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / nindy-share / coff.h < prev    next >
C/C++ Source or Header  |  1992-09-11  |  10KB  |  333 lines

  1. /* This is a coff version of a.out.h to support 80960 debugging from
  2.  * a Unix (possibly BSD) host.  It's used by:
  3.  *    o gdb960 to symbols in code generated with Intel (non-GNU) tools.
  4.  *    o comm960 to convert a b.out file to a coff file for download.
  5.  */
  6.  
  7.  
  8. /********************** FILE HEADER **********************/
  9.  
  10. struct filehdr {
  11.     unsigned short    f_magic;    /* magic number            */
  12.     unsigned short    f_nscns;    /* number of sections        */
  13.     long        f_timdat;    /* time & date stamp        */
  14.     long        f_symptr;    /* file pointer to symtab    */
  15.     long        f_nsyms;    /* number of symtab entries    */
  16.     unsigned short    f_opthdr;    /* sizeof(optional hdr)        */
  17.     unsigned short    f_flags;    /* flags            */
  18. };
  19.  
  20.  
  21. /* Bits for f_flags:
  22.  *    F_RELFLG    relocation info stripped from file
  23.  *    F_EXEC        file is executable (no unresolved externel references)
  24.  *    F_LNNO        line nunbers stripped from file
  25.  *    F_LSYMS        local symbols stripped from file
  26.  *    F_AR32WR    file has byte ordering of an AR32WR machine (e.g. vax)
  27.  */
  28. #define F_RELFLG    0000001
  29. #define F_EXEC        0000002
  30. #define F_LNNO        0000004
  31. #define F_LSYMS    0000010
  32. #define F_AR32WR    0000400
  33.  
  34.  
  35. /*
  36.  *    Intel 80960 (I960) processor flags.
  37.  *    F_I960TYPE == mask for processor type field. 
  38.  */
  39. #define    F_I960TYPE        0170000
  40. #define    F_I960CA        0010000
  41. #define F_I960FLOAT        0020000
  42. #define F_I960BA        0030000
  43. #define F_I960XA        0040000
  44.  
  45. /*
  46.  * i80960 Magic Numbers
  47.  */
  48. #define I960ROMAGIC    0540    /* read-only text segments    */
  49. #define I960RWMAGIC    0541    /* read-write text segments    */
  50.  
  51. #define I960BADMAG(x) (((x).f_magic!=I960ROMAGIC) && ((x).f_magic!=I960RWMAGIC))
  52.  
  53. #define    FILHDR    struct filehdr
  54. #define    FILHSZ    sizeof(FILHDR)
  55.  
  56.  
  57. /********************** AOUT "OPTIONAL HEADER" **********************/
  58.  
  59. typedef struct {
  60.     unsigned long    phys_addr;
  61.     unsigned long    bitarray;
  62. } TAGBITS;
  63.  
  64. typedef    struct aouthdr {
  65.     short        magic;    /* type of file                */
  66.     short        vstamp;    /* version stamp            */
  67.     unsigned long    tsize;    /* text size in bytes, padded to FW bdry*/
  68.     unsigned long    dsize;    /* initialized data "  "        */
  69.     unsigned long    bsize;    /* uninitialized data "   "        */
  70. #if U3B
  71.     unsigned long    dum1;
  72.     unsigned long    dum2;    /* pad to entry point    */
  73. #endif
  74.     unsigned long    entry;    /* entry pt.                */
  75.     unsigned long    text_start;    /* base of text used for this file */
  76.     unsigned long    data_start;    /* base of data used for this file */
  77.     unsigned long    tagentries;    /* number of tag entries to follow */
  78. } AOUTHDR;
  79.  
  80. /* return a pointer to the tag bits array */
  81.  
  82. #define TAGPTR(aout) ((TAGBITS *) (&(aout.tagentries)+1))
  83.  
  84. /* compute size of a header */
  85.  
  86. #define AOUTSZ(aout) (sizeof(AOUTHDR)+(aout.tagentries*sizeof(TAGBITS)))
  87.  
  88. /********************** STORAGE CLASSES **********************/
  89.  
  90. #define C_EFCN        -1    /* physical end of function    */
  91. #define C_NULL        0
  92. #define C_AUTO        1    /* automatic variable        */
  93. #define C_EXT        2    /* external symbol        */
  94. #define C_STAT        3    /* static            */
  95. #define C_REG        4    /* register variable        */
  96. #define C_EXTDEF    5    /* external definition        */
  97. #define C_LABEL        6    /* label            */
  98. #define C_ULABEL    7    /* undefined label        */
  99. #define C_MOS        8    /* member of structure        */
  100. #define C_ARG        9    /* function argument        */
  101. #define C_STRTAG    10    /* structure tag        */
  102. #define C_MOU        11    /* member of union        */
  103. #define C_UNTAG        12    /* union tag            */
  104. #define C_TPDEF        13    /* type definition        */
  105. #define C_USTATIC    14    /* undefined static        */
  106. #define C_ENTAG        15    /* enumeration tag        */
  107. #define C_MOE        16    /* member of enumeration    */
  108. #define C_REGPARM    17    /* register parameter        */
  109. #define C_FIELD        18    /* bit field            */
  110. #define C_BLOCK        100    /* ".bb" or ".eb"        */
  111. #define C_FCN        101    /* ".bf" or ".ef"        */
  112. #define C_EOS        102    /* end of structure        */
  113. #define C_FILE        103    /* file name            */
  114. #define C_LINE        104    /* line # reformatted as symbol table entry */
  115. #define C_ALIAS         105    /* duplicate tag        */
  116. #define C_HIDDEN    106    /* ext symbol in dmert public lib */
  117.  
  118.     /* New storage classes for 80960 */
  119.  
  120. #define C_SCALL        107    /* Procedure reachable via system call    */
  121. #define C_LEAFPROC    108    /* Leaf procedure, "call" via BAL    */
  122.  
  123.  
  124. /********************** SECTION HEADER **********************/
  125.  
  126. struct scnhdr {
  127.     char        s_name[8];    /* section name            */
  128.     long        s_paddr;    /* physical address, aliased s_nlib */
  129.     long        s_vaddr;    /* virtual address        */
  130.     long        s_size;        /* section size            */
  131.     long        s_scnptr;    /* file ptr to raw data for section */
  132.     long        s_relptr;    /* file ptr to relocation    */
  133.     long        s_lnnoptr;    /* file ptr to line numbers    */
  134.     unsigned short    s_nreloc;    /* number of relocation entries    */
  135.     unsigned short    s_nlnno;    /* number of line number entries*/
  136.     long        s_flags;    /* flags            */
  137.     unsigned long    s_align;    /* section alignment        */
  138. };
  139.  
  140. /*
  141.  * names of "special" sections
  142.  */
  143. #define _TEXT    ".text"
  144. #define _DATA    ".data"
  145. #define _BSS    ".bss"
  146.  
  147. /*
  148.  * s_flags "type"
  149.  */
  150. #define    STYP_TEXT    0x20        /* section contains text only    */
  151. #define STYP_DATA    0x40        /* section contains data only    */
  152. #define STYP_BSS    0x80        /* section contains bss only    */
  153.  
  154. #define    SCNHDR    struct scnhdr
  155. #define    SCNHSZ    sizeof(SCNHDR)
  156.  
  157.  
  158. /********************** LINE NUMBERS **********************/
  159.  
  160. /* 1 line number entry for every "breakpointable" source line in a section.
  161.  * Line numbers are grouped on a per function basis; first entry in a function
  162.  * grouping will have l_lnno = 0 and in place of physical address will be the
  163.  * symbol table index of the function name.
  164.  */
  165. struct lineno{
  166.     union {
  167.         long l_symndx;    /* function name symbol index, iff l_lnno == 0*/
  168.         long l_paddr;    /* (physical) address of line number    */
  169.     } l_addr;
  170.     unsigned short    l_lnno;    /* line number        */
  171.     char padding[2];    /* force alignment    */
  172. };
  173.  
  174. #define    LINENO    struct lineno
  175. #define    LINESZ    sizeof(LINENO) 
  176.  
  177.  
  178. /********************** SYMBOLS **********************/
  179.  
  180. #define SYMNMLEN    8    /* # characters in a symbol name    */
  181. #define FILNMLEN    14    /* # characters in a file name        */
  182. #define DIMNUM        4    /* # array dimensions in auxiliary entry */
  183.  
  184.  
  185. struct syment {
  186.     union {
  187.         char    _n_name[SYMNMLEN];    /* old COFF version    */
  188.         struct {
  189.             long    _n_zeroes;    /* new == 0        */
  190.             long    _n_offset;    /* offset into string table */
  191.         } _n_n;
  192.         char    *_n_nptr[2];    /* allows for overlaying    */
  193.     } _n;
  194.     long        n_value;    /* value of symbol        */
  195.     short        n_scnum;    /* section number        */
  196.     char        pad1[2];    /* force alignment        */
  197.     unsigned long    n_type;        /* type and derived type    */
  198.     char        n_sclass;    /* storage class        */
  199.     char        n_numaux;    /* number of aux. entries    */
  200.     char        pad2[2];    /* force alignment        */
  201. };
  202.  
  203. #define n_name        _n._n_name
  204. #define n_zeroes    _n._n_n._n_zeroes
  205. #define n_offset    _n._n_n._n_offset
  206.  
  207. /*
  208.  * Relocatable symbols have number of the section in which they are defined,
  209.  * or one of the following:
  210.  */
  211. #define N_UNDEF    0    /* undefined symbol                */
  212. #define N_ABS    -1    /* value of symbol is absolute            */
  213. #define N_DEBUG    -2    /* debugging symbol -- symbol value is meaningless */
  214.  
  215. /*
  216.  * Type of a symbol, in low 4 bits of the word
  217.  */
  218. #define T_NULL        0
  219. #define T_VOID        1    /* function argument (only used by compiler) */
  220. #define T_CHAR        2    /* character        */
  221. #define T_SHORT        3    /* short integer    */
  222. #define T_INT        4    /* integer        */
  223. #define T_LONG        5    /* long integer        */
  224. #define T_FLOAT        6    /* floating point    */
  225. #define T_DOUBLE    7    /* double word        */
  226. #define T_STRUCT    8    /* structure         */
  227. #define T_UNION        9    /* union         */
  228. #define T_ENUM        10    /* enumeration         */
  229. #define T_MOE        11    /* member of enumeration*/
  230. #define T_UCHAR        12    /* unsigned character    */
  231. #define T_USHORT    13    /* unsigned short    */
  232. #define T_UINT        14    /* unsigned integer    */
  233. #define T_ULONG        15    /* unsigned long    */
  234. #define T_LNGDBL    16    /* long double        */
  235.  
  236.  
  237. /*
  238.  * derived types
  239.  */
  240. #define DT_PTR        1    /* pointer    */
  241. #define DT_FCN        2    /* function    */
  242. #define DT_ARY        3    /* array    */
  243.  
  244. #define N_BTMASK    037
  245. #define N_TMASK        0140
  246. #define N_BTSHFT    5
  247. #define N_TSHIFT    2
  248.  
  249. #define BTYPE(x)    ((x) & N_BTMASK)
  250.  
  251.  
  252. #define ISPTR(x)    (((x) & N_TMASK) == (DT_PTR << N_BTSHFT))
  253. #define ISFCN(x)    (((x) & N_TMASK) == (DT_FCN << N_BTSHFT))
  254. #define ISARY(x)    (((x) & N_TMASK) == (DT_ARY << N_BTSHFT))
  255.  
  256. #define DECREF(x) ((((x)>>N_TSHIFT)&~N_BTMASK)|((x)&N_BTMASK))
  257.  
  258. union auxent {
  259.     struct {
  260.         long x_tagndx;    /* str, un, or enum tag indx */
  261.         union {
  262.             struct {
  263.                 unsigned short x_lnno; /* declaration line number */
  264.                 unsigned short x_size; /* str/union/array size */
  265.             } x_lnsz;
  266.             long x_fsize;    /* size of function */
  267.         } x_misc;
  268.         union {
  269.             struct {        /* if ISFCN, tag, or .bb */
  270.                 long x_lnnoptr;    /* ptr to fcn line # */
  271.                 long x_endndx;    /* entry ndx past block end */
  272.             } x_fcn;
  273.             struct {        /* if ISARY, up to 4 dimen. */
  274.                 unsigned short x_dimen[DIMNUM];
  275.             } x_ary;
  276.         } x_fcnary;
  277.         unsigned short x_tvndx;        /* tv index */
  278.     } x_sym;
  279.  
  280.     union {
  281.         char x_fname[FILNMLEN];
  282.         struct {
  283.             long x_zeroes;
  284.             long x_offset;
  285.         } x_n;
  286.     } x_file;
  287.  
  288.     struct {
  289.         long x_scnlen;            /* section length */
  290.         unsigned short x_nreloc;    /* # relocation entries */
  291.         unsigned short x_nlinno;    /* # line numbers */
  292.     } x_scn;
  293.  
  294.     struct {
  295.         long x_stdindx;
  296.     } x_sc;
  297.  
  298.     struct {
  299.         unsigned long x_balntry;
  300.     } x_bal;
  301.  
  302.     char a[sizeof(struct syment)];    /* force auxent/syment sizes to match */
  303. };
  304.  
  305. #define    SYMENT    struct syment
  306. #define    SYMESZ    sizeof(SYMENT)    
  307. #define    AUXENT    union auxent
  308. #define    AUXESZ    sizeof(AUXENT)
  309.  
  310. #if VAX || I960
  311. #    define _ETEXT    "_etext"
  312. #else
  313. #    define _ETEXT    "etext"
  314. #endif
  315.  
  316. /********************** RELOCATION DIRECTIVES **********************/
  317.  
  318. struct reloc {
  319.     long r_vaddr;        /* Virtual address of reference */
  320.     long r_symndx;        /* Index into symbol table    */
  321.     unsigned short r_type;    /* Relocation type        */
  322.     char pad[2];        /* Unused            */
  323. };
  324.  
  325. /* Only values of r_type GNU/960 cares about */
  326. #define R_RELLONG    17    /* Direct 32-bit relocation        */
  327. #define R_IPRMED    25    /* 24-bit ip-relative relocation    */
  328. #define R_OPTCALL    27    /* 32-bit optimizable call (leafproc/sysproc) */
  329.  
  330.  
  331. #define RELOC struct reloc
  332. #define RELSZ sizeof(RELOC)
  333.